package cc.booku.owlbox.Statistics;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.concurrent.Executors;

import cc.booku.owlbox.R;
import cc.booku.owlbox.UnSearchPage.AsyncTaskImageLoad;
import cc.booku.owlbox.UnSearchPage.Search_C;

public class eq_detail_A extends BaseAdapter implements ListAdapter {


    private ArrayList<eq_detail_C> eq_detail_cArrayList;
    private int id;
    private Context context;
    private LayoutInflater inflater;

    public eq_detail_A(int item, Context context, ArrayList<eq_detail_C> eq_detail_cArrayList) {
        this.eq_detail_cArrayList = eq_detail_cArrayList;
        this.context = context;
        this.id = item;
        inflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return eq_detail_cArrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return eq_detail_cArrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }


    @SuppressLint("WrongConstant")
    @Override

    public View getView(final int i, View view, ViewGroup viewGroup) {

//String vod_date,vod_device,vod_model,vod_version,vod_ip,vod_username;
        TextView vod_date = null;
        TextView vod_device = null;
        TextView vod_model = null;
        TextView vod_version = null;
        TextView vod_ip = null;
        TextView vod_username = null;


        eq_detail_A.ViewHolder viewHolder;
        if (view == null) {
            view = inflater.inflate(id, null);

            vod_date = (TextView) view.findViewById(R.id.tv_date);
            vod_device = (TextView) view.findViewById(R.id.tv_device);
            vod_model = (TextView) view.findViewById(R.id.tv_model);
            vod_version = (TextView) view.findViewById(R.id.tv_version);
            vod_ip = (TextView) view.findViewById(R.id.tv_ip);
            vod_username = (TextView) view.findViewById(R.id.tv_username);


            view.setTag(new ViewHolder(vod_date, vod_device, vod_model, vod_version, vod_ip, vod_username));
        } else {
            eq_detail_A.ViewHolder viewHolder1 = (eq_detail_A.ViewHolder) view.getTag(); // 重新获取ViewHolder
            vod_date = viewHolder1.vod_date;
            vod_device = viewHolder1.vod_device;
            vod_model = viewHolder1.vod_model;
            vod_version = viewHolder1.vod_version;
            vod_ip = viewHolder1.vod_ip;
            vod_username = viewHolder1.vod_username;


        }
        eq_detail_C cc = (eq_detail_C) eq_detail_cArrayList.get(i); // 获取当前项的实例

        //video_public_classListc
        vod_date.setText(cc.getVod_date().toString());//对象为空
        vod_device.setText(cc.getVod_device().toString());
        vod_model.setText(cc.getVod_model().toString());
        vod_version.setText(cc.getVod_version().toString());
        vod_ip.setText(cc.getVod_ip().toString());
        vod_username.setText(cc.getVod_username().toString());


        return view;

    }


    private final class ViewHolder {
        TextView vod_date = null;
        TextView vod_device = null;
        TextView vod_model = null;
        TextView vod_version = null;
        TextView vod_ip = null;
        TextView vod_username = null;


        public ViewHolder(TextView vod_date, TextView vod_device, TextView vod_model, TextView vod_version, TextView vod_ip, TextView vod_username) {
            this.vod_date = vod_date;
            this.vod_device = vod_device;
            this.vod_model = vod_model;
            this.vod_version = vod_version;
            this.vod_ip = vod_ip;
            this.vod_username = vod_username;


        }

    }
}